import moment from 'moment'

export function getRandomValue(field) {
  switch (field.type) {
    case 'input':
      return `${Math.random()
        .toString(36)
        .substring(11)}`
    case 'textarea':
      return `Random ${field.name} text ${Math.random()
        .toString(36)
        .substring(7)}`
    case 'select':
      return field.options[Math.floor(Math.random() * field.options.length)].value
    case 'date':
      return moment()
    case 'string(date-time)':
      return moment()
    case 'checkbox':
      return field.options.filter(() => Math.random() > 0.5).map(option => option.value)
    case 'upload':
      return '' // We can't generate a real file
    default:
      return `Random ${field.name}`
  }
}

